package com.ishopping.service.manage.mapper;

import com.github.abel533.mapper.Mapper;
import com.ishopping.api.manage.entity.Permission;
import com.ishopping.common.core.vo.TreeNode;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface PermissionMapper extends Mapper<Permission> {
    /**
     * 通过用户id获取用户具备的权限
     * @param userId
     * @param resourceType
     * @return List<Permission>
     */
    List<Permission> queryPermissionsByUserId(@Param("userId") Long userId, @Param("resourceType") String resourceType);

    /**
     * 获取菜单下的操作资源
     * @param menuId
     * @return List<Permission>
     */
    public List<Permission> queryOperations(@Param("menuId") Long menuId, @Param("resourceType") String resourceType);

    /**
     * 获取菜单信息
     * @param resourceType
     * @return List<Permission>
     */
    List<Permission> queryMenus(@Param("resourceType") String resourceType);

    /**
     * 加载权限树
     * @param roleId
     * @return List<TreeNode>
     */
    List<TreeNode> queryTreeNodes(Long roleId);
}